package de.jaydev.springconfig;

import javax.servlet.Filter;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class Initializer extends
    AbstractAnnotationConfigDispatcherServletInitializer
{
    
    @Override
    public void onStartup(ServletContext container) throws ServletException
    {
        org.springframework.web.util.Log4jConfigListener log4jConfigListener = new org.springframework.web.util.Log4jConfigListener();
        container.addListener(log4jConfigListener);
        super.onStartup(container);
    }
    
    @Override
    protected Class<?>[] getRootConfigClasses()
    {
        return new Class[] { WebSecurityConfig.class };
    }
    
    @Override
    protected Class<?>[] getServletConfigClasses()
    {
        return new Class[] { WebConfig.class };
    }
    
    @Override
    protected String[] getServletMappings()
    {
        return new String[] { "/" };
    }
    
    @Override
    protected Filter[] getServletFilters()
    {
        return new Filter[] { new DelegatingFilterProxy(
            "springSecurityFilterChain") };
    }
}